﻿using UnityEngine;
using System.Collections;

public class DeathParticles : MonoBehaviour {

	private ParticleSystem deathParticle;
	private bool isStart;

	// Use this for initialization
	void Start () {
		deathParticle = GetComponent<ParticleSystem> ();
	}
	
	// Update is called once per frame
	void Update () {
		if (isStart && deathParticle.isStopped) {
			Destroy (gameObject);
		}
	}

	public void Active() {
		isStart = true;
		deathParticle.Play ();
	}

	public void SetDeathFloor(GameObject deathFloor) {
		if (deathParticle == null) {
			deathParticle = GetComponent<ParticleSystem> ();
		} else {
			deathParticle.collision.SetPlane (0, deathFloor.transform);
		}
	}
}
